package com.chenxbook.modules.examples.decision;

import org.jbpm.api.jpdl.DecisionHandler;
import org.jbpm.api.model.OpenExecution;

/**
 * 定义处理器ContentEvaluation类
 * <br> 实现DecisionHandler接口，将流转判断的决定权委派给这个实现类。
 *
 * @author chenxbook
 * @date 2020-06-01
 **/
public class ContentEvaluation implements DecisionHandler {

    private static final long serialVersionUID = 1L;

    /**
     * Description
     * <br>  返回字符串的转移名称
     *
     * @param execution 流程实例的执行上下文
     * @return
     * @date
     * @author chenxbook
     **/
    public String decide(OpenExecution execution) {
        String content = (String) execution.getVariable("content");
        if (content.equals("you're great")) {
            return "good";
        }
        if (content.equals("you gotta improve")) {
            return "bad";
        }
        return "ugly";
    }
}